<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>后退</button>
    <a href="http://www.baidu.com">百度</a>
    <span>前进</span>

    <div>随便</div>
    <script>
        // history:浏览器回话历史记录
        document.querySelector('button').onclick=function(){
            // 返回上一页
            history.back()
        }
         document.querySelector('span').onclick=function(){
            // 前进
            history.forward()
        }
          document.querySelector('div').onclick=function(){
            // 通过设置go的参数跳转
            history.go(-2)
        }
        
        
    </script>
</body>
</html>